home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 1 / BBS in a box - Trilogy I.iso / Files / Art / Art Tools / Image 1.49 Folder / Image 1.49 / Macros / Gel Plotting Macros < prev    next >
Encoding:
Text File  |  1993-03-31  |  4.7 KB  |  177 lines  |  [TEXT/ttxt]

  1. var  {Global variables}
  2.   RoiLeft,RoiTop,RoiWidth,RoiHeight,PlotColor:integer;
  3.   GelWidth,GelHeight,MaxPlotWindowHeight:integer;
  4.   GelWindow,PlotWindow,PlotLeft,PlotTop,PlotWidth,PlotHeight:integer;
  5.   hMargin,vMargin,nLanes,SavePlotTop:integer;
  6.   LeftMargin,TopMargin,RightMargin,BottomMargin:integer;
  7.   FirstBackgroundPlot:boolean;
  8.  
  9. macro 'Setup to Plot Gel [Z]';
  10. {This macro, along with the Plot Lane macro, is used to generate profile}
  11. {plots of the lanes in a one dimensional electoproretic gel.}
  12. var
  13.   nPixels,mean,mode,min,max:real;
  14.   PlotWinHeight:integer;
  15. begin
  16.   RequiresVersion(1.48);
  17.   PlotHeight:=175;
  18.   PlotWidth:=500;
  19.   MaxPlotWindowHeight:=720;
  20.   GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight);
  21.   if RoiWidth=0 then begin
  22.     PutMessage('The Setup macro expects the Gel to be displayed and the first lane outlined.');
  23.     exit;
  24.   end;
  25.   if PlotWidth<RoiWidth then PlotWidth:=RoiWidth;
  26.   if PlotWidth>(2*RoiWidth) then PlotWidth:=2*RoiWidth;
  27.   if RoiHeight>RoiWidth then begin
  28.     PutMessage('Lanes must be horizontal.');
  29.     exit;
  30.   end;
  31.   if nPics<>1 then begin
  32.     PutMessage('The window containing the gel should be the only image window open.');
  33.     exit;
  34.   end;
  35.   nLanes:=GetNumber('Number of lanes?',1);
  36.   GetPicSize(GelWidth,GelHeight);
  37.   MakeRoi(RoiLeft,RoiTop,RoiWidth,GelHeight-RoiTop);
  38.   Measure;
  39.   GetResults(nPixels,mean,mode,min,max);
  40.   hMargin:=5;
  41.   vMargin:=5;
  42.   if Calibrated
  43.     then LeftMargin:=35
  44.     else LeftMargin:=25;
  45.   TopMargin:=10;
  46.   RightMargin:=20;
  47.   BottomMargin:=20;
  48.   PlotLeft:=hMargin-LeftMargin;
  49.   PlotTop:=vMargin-TopMargin;
  50.   SavePlotTop:=PlotTop;
  51.   PlotWinHeight:=nLanes*PlotHeight+2*vMargin;
  52.   if PlotWinHeight>MaxPlotWindowHeight then begin
  53.     PlotWinHeight:=MaxPlotWindowHeight;
  54.     PlotHeight:=(PlotWinHeight-2*vMargin)/nLanes;
  55.   end;
  56.   SetNewSize(PlotWidth+2*hMargin,PlotWinHeight);
  57.   SetForegroundColor(255);
  58.   SetBackgroundColor(0);
  59.   MakeNewWindow('Plots');
  60.   SetPlotSize(PlotWidth,PlotHeight);
  61.   min:=min-1;
  62.   if min<0 then min:=0;
  63.   max:=max+5;
  64.   if max>255 then max:=255;
  65.   SetPlotScale(cValue(min),cValue(max));
  66.   SetPlotLabels(false);
  67.   GelWindow:=1;
  68.   PlotWindow:=2;
  69.   SelectPic(GelWindow);
  70.   MakeRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight);
  71.   FirstBackgroundPlot:=true;
  72.   PlotColor:=1;
  73.   ResetCounter;
  74.   MeasureArea(true);
  75.   MeasureDensity(false);
  76.   WandAutoMeasure(true);
  77.   AdjustAreas(true);
  78.   LabelParticles(false);
  79.   IncludeInteriorHoles(true);
  80.   SetFontSize(9);
  81.   SetText('Centered');
  82.   SetLineWidth(1);
  83. end;
  84.  
  85.  
  86. macro 'Plot Lane [P]';
  87. var
  88.   left,top,width,height:integer;
  89.   GelNotCalibrated:boolean;
  90. begin
  91.   if (GelWidth=0) or (nPics=1) then begin
  92.     PutMessage
  93.       ('Before using the Plot Lane macro you must first use the Setup macro.');
  94.     Exit;
  95.   end;
  96.   GelNotCalibrated:=not Calibrated;
  97.   GetRoi(left,top,width,height);
  98.   MakeRoi(RoiLeft,top,RoiWidth,RoiHeight);
  99.   SetOption;
  100.   ColumnAveragePlot;
  101.   Copy;
  102.   SelectPic(PlotWindow);
  103.   MakeRoi(PlotLeft,PlotTop,PlotWidth+LeftMargin+RightMargin,
  104.           PlotHeight+TopMargin+BottomMargin);
  105.   Paste;
  106.   DoOr;
  107.   if GelNotCalibrated and (PlotTop=SavePlotTop) then begin
  108.     SetText('Left Justified; With Background');
  109.     MoveTo(PlotLeft+LeftMargin+6,PlotTop+TopMargin+1);
  110.     SetFontSize(12);
  111.     Write('Uncalibrated');
  112.     SetFontSize(9);
  113.     SetText('Centered; No Background');
  114.   end;
  115.   PlotTop:=PlotTop+PlotHeight-1;
  116.   SelectPic(GelWindow);
  117. end;
  118.  
  119.  
  120. macro 'Plot Background Lane [B]';
  121. {Plot all lanes before plotting backgrounds. Unlike the lane plotting macro,}
  122. {you are allowed to change the height of the selection.}
  123. var
  124.   left,top,width,height:integer;
  125. begin
  126.   if (GelWidth=0) or (nPics=1) then begin
  127.     PutMessage('Use Setup first.');
  128.     Exit;
  129.   end;
  130.   GetRoi(left,top,width,height);
  131.   MakeRoi(RoiLeft,top,RoiWidth,height);
  132.   ColumnAveragePlot;
  133.   Copy;
  134.   SelectPic(PlotWindow);
  135.   if FirstBackgroundPlot then begin
  136.     FirstBackgroundPlot:=false;
  137.     PlotTop:=SavePlotTop;
  138.   end;
  139.   MakeRoi(PlotLeft,PlotTop,PlotWidth+LeftMargin+RightMargin,
  140.           PlotHeight+TopMargin+BottomMargin);
  141.   Paste;
  142.   DoOr;
  143.   PlotTop:=PlotTop+PlotHeight-1;
  144.   SelectPic(GelWindow);
  145. end;
  146.  
  147.  
  148. macro 'Plot Overlayed [O]';
  149. var
  150.   left,top,width,height:integer;
  151. begin
  152.   if (GelWidth=0) or (nPics=1) then begin
  153.     PutMessage('Use Setup first.');
  154.     Exit;
  155.   end;
  156.   if PlotColor=1 then SetPalette('256 Color Spectrum');
  157.   GetRoi(left,top,width,height);
  158.   MakeRoi(RoiLeft,top,RoiWidth,height);
  159.   ColumnAveragePlot;
  160.   Copy;
  161.   SelectPic(PlotWindow);
  162.   if PlotColor=1 then SetPalette('256 Color Spectrum');
  163.   SetForegroundColor(PlotColor);
  164.   PlotTop:=PlotTop-PlotHeight+1;
  165.   if PlotTop<SavePlotTop then PlotTop:=SavePlotTop;
  166.   MakeRoi(PlotLeft,PlotTop,PlotWidth+LeftMargin+RightMargin,
  167.           PlotHeight+TopMargin+BottomMargin);
  168.   Paste;
  169.   DoOr;
  170.   PlotTop:=PlotTop+PlotHeight-1;
  171.   SelectPic(GelWindow);
  172.   PlotColor:=(PlotColor+74) mod 254;
  173. end;
  174.  
  175.  
  176.  
  177.